package com.maoxs;

import com.maoxs.pojo.User;
import com.maoxs.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/getUserKeyGen/{id}")
    public void getUserKeyGen(@PathVariable("id") Long id) {
        User userKeyGen = userService.getUserKeyGen(id);
        System.out.println(userKeyGen);
    }

    @RequestMapping("/getUserByManager")
    public void getUserByManager() {
        userService.getUserByManager();
    }

    @RequestMapping("/getUser/{id}")
    public void getUser(@PathVariable("id") Long id) {
        User user = userService.getUser(id);
        System.out.println(user);
    }

    @RequestMapping("/saveOrUpdate/{id}")
    public void saveOrUpdate(@PathVariable("id") Long id) {
        User user = new User(3L, "我的的的的的");
        userService.saveOrUpdate(id, user);
    }

    @RequestMapping("/delete/{id}")
    public void delete(@PathVariable("id") Long id) {
        userService.delete(id);
    }

}
